
#ifndef __SECURITY_TOKEN_INTERACTIVE_H
#define __SECURITY_TOKEN_INTERACTIVE_H

#include "SecurityToken.h"

/** Function type for callback with interactive authentication. */
typedef void (*stoken_interactive_functor)(const char *, int,
   const char *, int, int, const LIBSSH2_USERAUTH_KBDINT_PROMPT *,
   LIBSSH2_USERAUTH_KBDINT_RESPONSE *, void **);

/** A security token based on some interactive prompt (assumed to be a
 * password prompt). */
class SecurityTokenInteractive : public SecurityToken
{
   public:
      SecurityTokenInteractive(const char *ipassword);
      virtual ~SecurityTokenInteractive();
      static void *interactiveCallback(const char *name, int name_len,
         const char *instruction, int instruction_len, int num_prompts,
         const LIBSSH2_USERAUTH_KBDINT_PROMPT *prompts,
         LIBSSH2_USERAUTH_KBDINT_RESPONSE *responses, void **abstract);
      virtual stoken_interactive_functor getInteractiveCallback() const
      {
         return (stoken_interactive_functor)(&interactiveCallback);
      }
      int authenticateSSHSession(LIBSSH2_SESSION *tsession, const char *username);
      virtual sshauthtype getAuthenticationType() { return SSH_AUTH_TYPE_INTERACTIVE; }
      virtual int wasTried() { return tried; }
   private:
      /** Password for the interactive security token. */
      char *password;
      /** Pointer pointer self. */
      SecurityToken *myself;
};

#endif
